<template>
	<view class="tab_contant">
		<view :class="showMore ? 'tab_more' : 'tab'">
			<view v-for='(item, index) in tabs' :key="index" :class="isActive == item.label ? 'active' : 'active1'"
				@click="chenked(item.label)">
				<view class="tab_itemtitle">{{item.text}}</view>
				<view class="tab_itembot"></view>
			</view>
		</view>
		<view class="more" v-if="showMore" @click="goMore()">
			<text class="txt">全部</text>
			<image :src="`${imgBasePath}/statics/std/static/new/arr_green.png`" mode=""></image>
		</view>
	</view>
</template>

<script>
	let img_api = process.env.VUE_APP_BASEURL_IMG_API;
	export default {
		props: {
			tabs: {
				required: true,
				type: Array,
				default () {
					return []
				}
			},
			showMore: {
				required: false,
				type: Boolean,
				default: false
			},
			selected: {
				required: true
			},
			live: {
				required: false,
				type: Boolean,
				default: false
			}
		},
		data() {
			return {
				imgBasePath: img_api,
				isActive: 1,
				lists: []
			};
		},
		computed: {

		},
		mounted() {
			this.isActive = this.selected
		},
		watch: {
		  tabs: {
		    handler(value) {
				if (value && value[0] && this.live) {
					this.chenked(value[0].label)
				}
		    },
		    immediate: true,
			deep: true
		  },
		},
		methods: {
			chenked(type) {
				this.isActive = type
				this.$emit('changeType', { type: type })
			},
			goMore() {
				this.$emit('more')
			}
		}
	}
</script>

<style lang="scss" scoped>
	.tab_contant {
		width: 100%;
		height: 48rpx;
		background: #FFFFFF;
		display: flex;
		align-items: center;
		justify-content: space-between;

		.more {
			width: 88rpx;
			height: 100%;
			display: flex;
			align-items: center;

			.txt {
				font-size: 28rpx;
				font-weight: 400;
				color: #87A198;
				line-height: 44rpx;
			}

			image {
				width: 32rpx;
				height: 32rpx;
				display: block;
			}
		}

		.tab_more {
			width: calc(100% - 88rpx);
			overflow-x: scroll;
			height: 100%;
			display: flex;
			align-items: baseline;
		}
		.tab {
			width: 100%;
			overflow-x: scroll;
			height: 100%;
			display: flex;
			align-items: baseline;
		}
		.active {
			box-sizing: border-box;
			padding-right: 32rpx;
		
			.tab_itemtitle {
				font-size: 32rpx;
				font-weight: 700;
				color: rgba(0, 0, 0, 0.8);
			}
		
			// .tab_itembot {
			// 	width: 63rpx;
			// 	margin-top: -20rpx;
			// 	height: 12rpx;
			// 	background: linear-gradient(90deg, #9CCCFF 0%, #62AEFF 100%);
			// }
		}
		
		.active1 {
			box-sizing: border-box;
			padding-right: 30rpx;
		
			.tab_itemtitle {
				font-size: 28rpx;
				font-weight: 400;
				color: rgba(0, 0, 0, 0.8);
			}
		
			.tab_itembot {
				height: 0px;
			}
		}
	}
</style>